package com.feifan.config;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author Donald
 * @create 2019-04-20 1:23
 * 配置AOP 切面
 */
@Component
@Aspect
public class AOP {
    /** 切入点表达式*/
    @Pointcut("execution(* com.feifan.web.controller.MyController.*(..))")
    public void pointcut(){}

    /**
     * 环切
     * @param proceedingJoinPoint
     */
    @Around("pointcut()")
    public Object loginAOP(ProceedingJoinPoint proceedingJoinPoint)
    {
        System.out.println(proceedingJoinPoint.getSignature().getName()+ proceedingJoinPoint.getArgs());
        Object proceed = null;
        try {
            proceed = proceedingJoinPoint.proceed();
            System.out.println("控制层正常执行之后");
        }catch (Throwable e)
        {
            System.out.println(String.format("方法执行异常{%s}",e));
        }
        return proceed;
    }


}
